// stores/counter.js
import { defineStore } from 'pinia'


interface MovieData {
  webName: string;
  webUrl: string;
  prefix: string;
  suffix: string;
  count: number
}

export const useMovieStore = defineStore('movie', {
  state: ():MovieData => {
    return { 
      webName: 'tiankongzy',
      webUrl: 'http://tiankongzy.cc',
      prefix: 'http://tiankongzy.cc/index.php/vod/search.html?wd=',
      suffix: '&submit=search',
      count: 0
    }
  },
  // could also be defined as
  // state: () => ({ count: 0 })
  actions: {
    increment(num: number) {
      this.count ++ 
      console.log('num', num)
    },
    storeMovieData(data: MovieData) {
      console.log('data', data)
      this.webName = data.webName
      this.webUrl = data.webUrl
      this.prefix = data.prefix
      this.suffix = data.suffix
    }
  }
})